const path = require('path')
const htmlWebpackPlugin = require('html-webpack-plugin')
// 导入每次删除dist目录插件
const { CleanWebpackPlugin } = require('clean-webpack-plugin')

const webpack = require('webpack')


module.exports  = {
  entry: {
    app: path.join(__dirname, './src/main.js'),//配置入口节点
    vendor: ['jquery'] //将要抽离的第三方名称，放入到数组中
  },
  output: {
    path: path.join(__dirname, "./dist"),
    filename: 'bundle.js'
  },
  plugins: [
    new htmlWebpackPlugin({
      template: path.join(__dirname, './src/index.html'),
      filename: 'index.html'
    }),
    new CleanWebpackPlugin()
  ],
    module: {
    rules: [
      {test: /\.css$/, use: ['style-loader', 'css-loader']},
      {test: /\.scss$/, use: ['style-loader', 'css-loader','sass-loader']},
      {test: /\.(png|jpg|jpeg|bmp|gif)$/, use: ['url-loader?limit=5000&name=images/[hash:8]-[name].[ext]']},
      {test: /\.js$/, use: 'babel-loader', exclude: /node_modules/ }
    ]
  }
} 